import { Component, OnInit } from '@angular/core';
//引入EventEmitService
import { EventEmitterService } from '../event-emitter.service';
@Component({
  selector: 'app-child',
  templateUrl: './child.component.html',
  styleUrls: ['./child.component.less']
})
export class ChildComponent implements OnInit {

  constructor(private eventEmitService: EventEmitterService) { }

  ngOnInit(): void {
    this.eventEmitService.myEventEmitter.subscribe(id => {
      //每当发生一次传参事件时，都会再次执行下面代码
      showParam(id);         //showParam(id){ console.log(id); }
    })
  }

}
function showParam(id: number) {
  console.log("child --- id",id);  
}

